﻿#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    bool IsNumberOrEnglish(char ch)
    {
        if (ch >= 'A' && ch <= 'Z')
        {
            return true;
        }
        if (ch >= 'a' && ch <= 'z')
        {
            return true;
        }
        if (ch >= '0' && ch <= '9')
        {
            return true;
        }

        return false;
    }
    bool isPalindrome(string s)
    {
        for (int i = 0; i < s.size(); ++i)
        {
            if (isupper(s[i]))
            {
                s[i] = s[i] + 'a' - 'A';
            }
        }
        string::iterator begin = s.begin();
        string::iterator end = s.end() - 1;
        while (begin < end)
        {
            while (!IsNumberOrEnglish(*begin) && begin < end)
            {
                begin++;
            }
            while (!IsNumberOrEnglish(*end) && begin < end)
            {
                end--;
            }
            if (*begin != *end)
            {
                return false;
            }
            begin++;
            end--;
        }
        return true;
    }
};







